package com.ellen.mac.chatdemo;

import android.app.Application;
import android.util.Log;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVInstallation;
import com.avos.avoscloud.AVOSCloud;
import com.avos.avoscloud.PushService;
import com.avos.avoscloud.SaveCallback;
import com.avos.avoscloud.im.v2.AVIMClient;
import com.ellen.mac.chatdemo.activity.ImHomeActivty;
import com.ellen.mac.chatdemo.comment.PicassoImageLoader;
import com.ellen.mac.chatdemo.model.CustomUserProvider;
import com.ellen.mac.chatdemo.utils.ChatKit;
import com.yanzhenjie.album.Album;
import com.yanzhenjie.album.AlbumConfig;

import java.util.Locale;

/**
 * Created by mac on 2017/11/29.
 */

public class App extends Application {
    private String Appid = "8Al24sdtMUh7vDDgBamB2NtC-gzGzoHsz";
    private String AppKey = "i7kUSSQTJn7ePbW5vaySl1y6";

    @Override
    public void onCreate() {
        super.onCreate();
        Album.initialize(
                AlbumConfig.newBuilder(this)
                        .setAlbumLoader(new PicassoImageLoader())
                        .setLocale(Locale.ENGLISH)
                        .build()
        );
        // 初始化参数依次为 this, AppId, AppKey
        ChatKit.getInstance().setProfileProvider(CustomUserProvider.getInstance());
        ChatKit.getInstance().init(getApplicationContext(), Appid, AppKey);
        // 放在 SDK 初始化语句 AVOSCloud.initialize() 后面，只需要调用一次即可
        AVOSCloud.setDebugLogEnabled(true);
        //设置实时通信是否要在 App 重新启动后自动登录
        AVIMClient.setAutoOpen(false);
        AVInstallation.getCurrentInstallation().saveInBackground();
        PushService.setDefaultPushCallback(this, ImHomeActivty.class);

    }

}